<template>
  <div class="zyfc-box">
    <!-- <div class='job-banner ct'>
      <div class="banner-text">
        <div class="c-new-title">
          站院风采
        </div>
        <div class="c-new-text">
          “站院联建”农技推广服务平台
        </div>
      </div>
    </div> -->
    <div class="s-content ct">
      <div class="zyfc-content">
        <div class="zyfc-item" v-for="item in fengcais.list" @click="go(item)">
          <img :src="'https:'+ item._photo" alt="">
          <div class="zyfc-info">{{ item.courtyardName }}</div>
        </div>
      </div>
      <div class="item-page">
        <el-pagination
          :current-page="fengcais.page"
            :page-size="15"
            background
            layout="prev, pager, next, jumper"
            prev-text="上一页"
            next-text="下一页"
            :total="fengcais.total"
            @current-change="getPageCourtyardMien"
        />
      </div>
    </div>
  </div>
</template>  
<script setup>
  import { pageCourtyardMien } from '@/api/home';
  import { reactive } from 'vue';
  import { useRouter } from 'vue-router'

const router = useRouter()

  // 站院风采
  const fengcais = reactive({
    list: [],
    total: 0,
    page: 1,
  });

  const go = (item) => {
    const path = '/yardhome?yardId='+item.courtyardId
    window.open(`/#${path}`)
  }

  const getPageCourtyardMien =  async() => {
    const params = {
      params: {
        status: true,
      },
      page: {
        pageSize: 12,
        pageNum: 1,
      }
    }
    const ret = await pageCourtyardMien(params)
    try{
      ret?.data?.list.forEach(element => {
      if(element?.photo) {
        element._photo = JSON.parse(element?.photo)?.[0];
        console.log(element._photo)
      }
    });

      fengcais.list = ret?.data?.list || [];
      fengcais.total = ret?.data?.total;
      fengcais.page = pageNum;
    }catch{

    }
  }
  getPageCourtyardMien();
</script>
<style lang="scss" scoped>
.zyfc-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  color: #777;
  min-height: 900px;
  overflow: hidden;
  flex: 1;
  background: #f8f8f8 url('../../assets/job/6.png') no-repeat 0 200px;
  .job-banner {
    width: 100%;
    height: 280px;
    background: url(../../assets/zyfc/1.png) no-repeat center center / cover;
    padding: 0 10%;
    display: flex;
    align-items: center;
    color: #fff;
    .banner-text {
      padding-left: 30px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      position: relative;
      &::after {
        position: absolute;
        left: 0;
        top: 12px;
        height: 84%;
        width: 4px;
        background-color: #fff;
        content: ''
      }
      .c-new-title {
        font-weight: 700;
        font-size: 50px;
      }
      .c-new-text {
        font-size: 30px;
      }
    }
  }
  .s-content {
    padding: 0 10%;
    width: 100%;
  }
  .zyfc-content {
    padding-top: 50px;
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    .zyfc-item {
      min-height: 300px;
      width: 24%;
      margin-bottom: 20px;
      position: relative;
      cursor: pointer;
      margin-right: 20px;
      &:nth-of-type(4n) {
        margin-right: 0;
      }
      img {
        width: 100%;
        // height: 100%;
        // object-fit: contain;
        background-color: #fff;
      }
      .zyfc-info {
          position: absolute;
          bottom: 0;
          left: 0;
          height: .26042rem;
          width: 100%;
          background-color: #068043;
          color: #fff;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
        }
    }
  }
  .item-page {
      height: 160px;
      display: flex;
      align-items: center;
      justify-content: center;
      :deep(.el-pagination) {
        button, li {
          background-color: transparent;
          width: 50px;
          height: 50px;
          border: 2px solid #e5e5e5;
          border-radius: 5px;
          color: #777;
          font-size: 24px;
          font-weight: normal;
          margin-right: 30px;
        }
        button {
          border: 0 none;
        }
        .el-pagination__jump {
          color: #777;
          font-size: 26px;
        }
        .el-pagination__editor {
          min-width: 50px;
          min-height: 50px;
          font-size: 24px;
        }
        .el-input__wrapper {
          padding: 0;
        }
        .el-input__inner {
          color: #777 !important;
        }
      }
    }
}
</style>